package com.grablist.feihu.grablist.ui.actviity.user.biz;

import com.grablist.feihu.grablist.base.BaseBiz;
import com.grablist.feihu.grablist.base.BaseResp;
import com.grablist.feihu.grablist.comm.BaseSubscribe2;
import com.grablist.feihu.grablist.comm.RetrofitHelp;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by admin on 2017/12/2.
 */

public class ResetPwdBiz extends BaseBiz {

    /**
     * 忘记密码
     * @param phone
     * @param pwd
     * @param callback
     */
    public void forgetPwd(String phone, String pwd, String code, final BaseBiz.Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().forgetPswCheck(phone, pwd,code)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }

    /**
     * 获取验证码
     *
     * @param phone
     * @param callback
     */
    public void mobileSms(String phone, Integer  type, final BaseBiz.Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().mobileSms(phone, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess(obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure(obj);
                    }
                })
        );
    }
}
